package ber.mcs;

import ber.mcs.Client;
import ber.mcs.Server;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;  
import android.content.Intent;
import android.os.Bundle;  
import android.os.Handler;  
import android.os.Message;  
import android.widget.TextView;  



public class UDPAndroidActivity extends Activity {
	Controlador controlador = new Controlador();
	static String[] filmes = new String[10];
	static Handler handler = new Handler() {
	public boolean array=false;
		  @Override
		  public void handleMessage(Message msg) {
			  Bundle b = msg.getData();
			  if (array){
				  filmes = b.getStringArray("teste");
				   Log.d("TESTE",Float.toString(filmes.length));
			  }
			  else{
				  Log.d("UDP","vfhjgfjn");
				  //mostrador.setText("Mensagem recebida:" + b.getString("teste"));
			  }
		     }
		 }; 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
    	TextView mostrador;
        super.onCreate(icicle);
        setContentView(R.layout.main);
        final Client client = new Client();
        Log.d("TESTE","1");
       new Thread(controlador).start();
       Log.d("TESTE","2");
       mostrador = (TextView) findViewById(R.id.hello);
        final Button enviarButton = (Button) findViewById(R.id.enviar);
        final Button receberButton = (Button) findViewById(R.id.receber);
        enviarButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	//startActivity(new Intent("android.intent.action.LISTVIEW"));
            	client.enviar("teste1");
            	}});
        receberButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            //mostrador.setText("Mensagem recebida:" + controlador.texto);
            	}});
    }
}